package com.jt.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jt.pojo.Item;
import com.jt.pojo.ItemDesc;
import com.jt.service.DubboItemService;
import com.jt.vo.EasyUITable;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.jt.service.ItemService;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/item")
public class ItemController {
	@Autowired
	private ItemService itemService;
	
	/*@Autowired
	private ItemService itemService;*/

	@RequestMapping("/query")
	public EasyUITable findItemByPage(int page,int rows){
		return itemService.findItemByPage(page,rows);
	}

	@RequestMapping("/save")
	public SysResult itemSave(Item item, ItemDesc itemDesc){
		itemService.saveItem(item,itemDesc);
		return SysResult.success();
	}
	@RequestMapping("/update")
	public SysResult updateItem(Item item,ItemDesc itemDesc){
		itemService.updateItem(item,itemDesc);
		return SysResult.success();
	}
	@RequestMapping("/delete")
	public SysResult deleteItem(Long... ids){
		itemService.deleteItems(ids);
		return SysResult.success();
	}
	@RequestMapping("/{status}")
	public SysResult updateStatus(Long[] ids,@PathVariable Integer status){
		itemService.updateStatus(ids,status);
		return SysResult.success();
	}
	@RequestMapping("/query/item/desc/{itemId}")
	public SysResult findItemById(@PathVariable Long itemId){
		ItemDesc itemDesc=itemService.findItemByDesc(itemId);
		return SysResult.success(itemDesc);
	}
	
}
